package com.example.demo.Dao;

import com.example.demo.Model.ArtInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface ArticleMapper {

    @Select("select * from articleinfo where uid = #{uid} order by id desc")
    List<ArtInfo> getArtById(@Param("uid")int uid);

    @Delete("delete Articleinfo from where id=#{aid} and uid=#{uid}")
    int del(Integer aid,int uid);

    @Insert("insert into articleinfo(title,content,uid) values (#{title},#{content},#{uid})")
     int add(ArtInfo artInfo);

    @Select("select * from articleinfo where id = #{aid} and uid = uid")
    ArtInfo getArticleByAid(@Param("aid")int aid,@Param("uid") int uid);

    @Update("update articleinfo set title=#{title},content=#{content} where id=#{id} and uid=#{uid}")
    int doupdate(ArtInfo artInfo);

    @Select("select * from articleinfo where id = #{aid}")
    ArtInfo getArticleById(@Param("aid")int aid);

    @Select("select count(*) from articleinfo where uid=#{uid}")
    int GetUserArtCount(@Param("uid")int uid);

    @Update("update articleinfo set rcount=rcount+1 where id=#{aid}")
    int incrementRCount(@Param("aid")int aid);

    @Select("select * from articleinfo order by id desc limit #{psize} offset #{offset}")
    List<ArtInfo> getListByPage(@Param("psize")int psize,@Param("offset")int offset);

    @Select("select count(*) from articleinfo")
    int getCount();
}
